| Conditions | 1 |
| Paths | 1 |
| Total Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 1 |
| CRAP Score | 1.729 |
| Changes | 0 | ||
| 1 | "use strict"; |
||
| 3 | 1 | exports.getInformation = (postId) => { |
|
| 4 | return fetch('http://localhost:3000/posts/' + postId) |
||
| 5 | .then((response) => response.json()) |
||
| 6 | .then((responseJson) => { |
||
| 7 | let jsonInfo = responseJson.json; |
||
| 8 | let information; |
||
| 9 | |||
| 10 | try { |
||
| 11 | let info = { |
||
| 12 | title: jsonInfo.items[0].title, |
||
| 13 | link: jsonInfo.items[0].link |
||
| 14 | }; |
||
| 15 | |||
| 16 | information = info; |
||
| 17 | } catch (e) { |
||
| 18 | console.error('\x1b[41m', 'Undefined map item', '\x1b[0m'); |
||
| 19 | } |
||
| 20 | // console.log("outsude"); |
||
| 21 | // console.log(information); |
||
| 22 | return information; |
||
|
|
|||
| 23 | }) |
||
| 24 | .catch((error) => { |
||
| 25 | console.error(error); |
||
| 26 | }); |
||
| 27 | }; |
||
| 28 | |||
| 53 |